// pages/classtype/classtype.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    til:[
      {id:0,tile:'手机'},
      {id:1,tile:'玩具'},
      {id:2,tile:'服装'},
      {id:3,tile:'鲜花'},
      {id:4,tile:'收藏品'},
      {id:5,tile:'饮食'},
      {id:6,tile:'全部'},
    ],
    commodity:[],
    commodityAll:[
      {id:0,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate1.jpg',classid:0},
      {id:1,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate2.jpg',classid:0},
      {id:2,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate3.jpg',classid:0},
      {id:3,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate4.jpg',classid:0},
      {id:4,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate5.jpg',classid:0},
      {id:5,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate6.jpg',classid:0},
      {id:6,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate7.jpg',classid:4},
      {id:7,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate8.jpg'  ,classid:3},
      {id:8,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate9.jpg'  ,classid:3},
      {id:9,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate10.jpg' ,classid:3},
      {id:10,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate11.jpg',classid:3},
      {id:11,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate12.jpg',classid:3},
      {id:12,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate13.jpg',classid:2},
      {id:13,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate14.jpg',classid:2},
      {id:14,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate15.jpg',classid:2},
      {id:15,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate16.jpg',classid:2},
      {id:16,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate17.jpg',classid:5},
      {id:17,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate18.jpg',classid:5},
      {id:18,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate19.jpg',classid:2},
      {id:19,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate20.jpg',classid:5},
      {id:20,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate21.jpg',classid:1},
      {id:21,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate22.jpg',classid:1},
      {id:22,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate23.jpg',classid:1},
      {id:23,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate24.jpg',classid:1},
    ],


  },
  search(e){
    var id = e.currentTarget.id
    var arr = this.data.commodityAll
    var arrs = []
    for(var i=0;i<arr.length;i++){
      if(arr[i].classid == id){
        arrs.push(arr[i])
      }
      if(arr[i].classid == 6){
        arrs.push(arr)
      }
    } 
    this.setData({
      commodity:arrs
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})